<%@page import="com.pb.poem.util.Page"%>
<%@page import="com.pb.poem.dao.impl.PoemDaoImpl"%>
<%@page import="com.pb.poem.service.PoemService"%>
<%@page import="java.util.List"%>
<%@page import="com.pb.poem.entity.Poem"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>

<%@ page language="java" contentType="text/html; charset=UTF-8"  pageEncoding="UTF-8"%>
<%@include file="../common/common.jsp"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
	function index() {
		window.location="goodfriend.jsp";
	}
	function oneself() {
		window.location="showoneself.jsp";
	}
	function page_nav( num) {
		var frm=document.getElementById("formpage");
		frm.pageIndex.value = num;
		frm.submit();
	}
	function jump_to(pageno) {
		var regexp = /^\d+$/;
		if (!regexp.test(pageno)) {
			alert("请输入正确的数字");
			return false;
		} else {
			page_nav(pageno);
		}
	}
</script>
</head>

<body>
  <table class="list">
	<c:forEach var="poem" items="${List}" varStatus="status">
						<table width="600" border="0">
							<tr>
								<td width="499" align="center">${poem.poemname}</td>
							</tr>
							<tr>
								<td align="center">${poem.dynasty}&nbsp;&nbsp;&nbsp;${poem.author}
								</td>
							</tr>
							<tr>
								<td align="center"  width="499" >${poem.content}</td>
							</tr>
						</table>
					</c:forEach>
					</tbody>
				</table>
	<form action="show.jsp" id="formpage" method="post">
	<input type="hidden" name="pageIndex" value="1" />
				<div>
					<li>共${totalCount}条记录&nbsp;&nbsp; ${pageIndex }/${totalPage}页</li>
					<c:if test="${pageIndex>1 }">
						<a href="javascript:page_nav(1)">首页</a>
						<a href="javascript:page_nav(${pageIndex - 1 })">上一页</a>
					</c:if>
					<c:if test="${pageIndex<totalPage }">
						<a href="javascript:page_nav(${pageIndex + 1 })">下一页</a>
						<a href="javascript:page_nav(${totalPage })">最后一页</a>
					</c:if>
					</ul>
					<span class="page-go-form"><label>跳转至</label> 
					<input type="text" name="inputPage1" id="inputPage" class="page-key" />页
						<button type="button" class="page-btn"
							onClick='jump_to(document.getElementById("inputPage").value)'>GO</button>
					</span>
				</div>	
	        <div>
				<input type="button" value="显示好友的诗" onclick="index();" />
			</div>
			<div>
				<input type="button" value="显示自己的诗" onclick="oneself();" />
			</div>
	   </form>
</body>
</html>